package com.woniu.zsd.recycle.service.impl;

import com.woniu.zsd.recycle.model.ErrorStatistics;
import com.woniu.zsd.recycle.mapper.ErrorStatisticsMapper;
import com.woniu.zsd.recycle.param.RecordingErrorParam;
import com.woniu.zsd.recycle.service.ErrorStatisticsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 彭于晏
 * @since 2025年02月18日
 */
@Service
public class ErrorStatisticsServiceImpl extends ServiceImpl<ErrorStatisticsMapper, ErrorStatistics> implements ErrorStatisticsService {
    @Resource
    private ErrorStatisticsMapper errorStatisticsMapper;
    @Override
    public void recordingError(RecordingErrorParam param) throws Exception {
        ErrorStatistics errorStatistics = new ErrorStatistics();
        errorStatistics.setRecyclingOrderDetailId(param.getRecyclingOrderDetailId());
        errorStatistics.setCreatedAt(LocalDateTime.now());
        errorStatistics.setDeviationReason(param.getDeviationReason());
        errorStatistics.setDeviationValue(param.getDeviationValue());
        errorStatistics.setUnit("kg");
        errorStatisticsMapper.insert(errorStatistics);
    }
}
